/*******************************************************************************
 *
 * Copyright (c) 2008-2011 ayound@gmail.com, guwei8576431@gmail.com
 * This program and the accompanying materials
 * are made available under the terms of the GNU GENERAL PUBLIC LICENSE
 * which accompanies this distribution, and is available at
 * http://dev.perl.org/licenses/gpl1.html
 * All rights reserved.
 *
 * Created on 2009-10-22
 *******************************************************************************/

package org.cgtw.scriptprofile.server.servlet.processor;

import org.cgtw.scriptprofile.server.manager.ProfileCycleManager;
import org.cgtw.scriptprofile.server.manager.ProfileParamsTranslator;
import org.cgtw.scriptprofile.server.servlet.ScriptProfileRequest;
import org.cgtw.scriptprofile.server.servlet.ScriptProfileResponse;
import org.json.JSONException;

public class ProfileProcessor extends AbstractProcessor{

	public ProfileProcessor(ScriptProfileRequest request, ScriptProfileResponse response) {
		super(request, response, null);
	}

	public void process() {
		if(!ProfileCycleManager.getInstance().isProfile()){
			getResponse().write("continue");
			getResponse().close();
			return;
		}
		getResponse().writeHTMLHeader("UTF-8", null);
		ProfileParamsTranslator translator = new ProfileParamsTranslator(getRequest().getPostData());
		try {
			translator.translator();
		} catch (JSONException e) {
			e.printStackTrace();
		}
		//here we should send update message to the view and send the continue message to the client
//		ProfileDataChangeListenerManager.getInstance().notify(data);
		getResponse().write("continue");
		getResponse().close();
	}

}
